package com.ce.webframework.sec.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;

import com.ce.webframework.sec.dao.ISecMenuitemDao;
import com.ce.webframework.sec.model.SecMenuitemDO;
import com.sitechasia.webx.core.dao.hibernate3.HibernateDomainObjectDao;

public class SecMenuitemDaoImpl extends HibernateDomainObjectDao<SecMenuitemDO> implements ISecMenuitemDao {

	/**
	 * 功能描述:通过权限查询菜单集合
	 * @param userId  用户标识
	 * @param funcodes 权限标识 集合
	 * @param epId  企业标识
	 * @return SecMenuitemVO 集合
	 */
	public List<SecMenuitemDO> getMenuItemList(List<String> funcodes, Long epId){
		List<SecMenuitemDO> userList = new ArrayList<SecMenuitemDO>();
		if(funcodes.size()==0){
				return userList;
		}

		String hql = " SELECT info FROM SecMenuitemDO info WHERE info.functionEntityId in (:funcodes) order by info.seq ";
		Query query = getSession().createQuery(hql);
		query.setParameterList("funcodes", funcodes);

		userList = query.list();

		return userList;
	}
	
	public List<SecMenuitemDO> getNavList(List<String> funcodes)
	  {
	    List userList = new ArrayList();
	    if (funcodes.size() == 0) {
	      return userList;
	    }

	    String hql = " SELECT info FROM SecMenuitemDO info WHERE info.lvl='1' and (info.navIcon <>'navIcon' OR info.navIcon IS NULL) and info.functionEntityId in (:funcodes) order by info.seq ";
	    Query query = getSession().createQuery(hql);
	    query.setParameterList("funcodes", funcodes);

	    userList = query.list();

	    return userList;
	  }
}
